﻿@using System
@using System.Data.SqlClient
@using System.Web.UI.WebControls
@using PagedList
@using PagedList.Mvc

@model PagedList.IPagedList<contos.Models.Student>
          
<link href="~/Content/newStyle.css" rel="stylesheet" />
<link href="~/Content/PagedList.css" rel="stylesheet" />
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>

<div>
    @using (Html.BeginForm())
    {
        <p>
        按姓名搜索:@Html.TextBox("searchstring",ViewBag.currectsFilter as string)
        <input type="submit" value="搜索" />
        </p>
    }
</div>
<table class="gridtable">
    <tr>
        <th>
           First Name
        </th>
        <th>
            @Html.ActionLink("LastName","Index",new {SortOrder=ViewBag.NamesortParm})
        </th>
        <th>
            @Html.ActionLink("Enrollment Date","Index",new {SortOrder=ViewBag.DatesortParm})
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.FirstMidName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.LastName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.EnrollmentDate)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id=item.StudentID }) |
                @Html.ActionLink("Details", "Details", new { id=item.StudentID }) |
                @Html.ActionLink("Delete", "Delete", new { id=item.StudentID })
            </td>
        </tr>
    }
        
</table>
<br />
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount

@Html.PagedListPager(Model, page => Url.Action("Index", new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
